﻿
<script src="jquery.js"></script>
<script type="text/javascript">
    //Ajax数据处理
    function jyDoAjaxCall(path, datatype, isLoading, data, callBackFunction) {
        var returnFun = null;
        var indexLoading = null;
        jQuery.ajax({
            async: callBackFunction == undefined || callBackFunction == null ? false : true, //true为异步方式
            type: 'POST',
            url: path,
            data: data,
            dataType: datatype,
            beforeSend: function () {
                if (isLoading) {
                    indexLoading = layer.load();
                }
            },
            complete: function () {
                if (isLoading && indexLoading != null) {
                    //layer.closeLoad();
                    layer.close(indexLoading);
                }
            },
            success: function (data, textStatus) {
                try {
                    var jsonData = eval(data);
                    if (jsonData == null || jsonData == undefined || jsonData.length < 0) {
                        alert("jsonData=null; length:" + jsonData.length);
                    }
                    returnFun = eval(jsonData[0]);
                    if ((callBackFunction != null && callBackFunction != undefined)
                        && (returnFun != null && returnFun != undefined)) {
                        callBackFunction(returnFun);
                    }
                }
                catch (err) {
                    alert("[SCRIPTS]异常[success]：" + err);
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert("[SCRIPTS]Error:\r\n1: " + jqXHR + "\r\n2: " + textStatus + "\r\n3: " + errorThrown);
            }
        });
        return returnFun;
    }

    alert(jyDoAjaxCall("JY.ashx", "json", false, { method: "test" }).zone);

    alert(jyDoAjaxCall("Handler.ashx", "json", false, { method: "test" }).zone);

    alert(jyDoAjaxCall("Handler2.ashx", "json", false, { method: "test" }).zone);

</script>
